package com.tlgen.coopera.config.disconf;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;

import java.util.Objects;

/**
 * 自定义属性配置源
 */
@Order
public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {

    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        PropertySource<?> propertySource = YmlPropertySourceFactory.loadProfiles();
        if(Objects.nonNull(propertySource)) {
            environment.getPropertySources().addLast(propertySource);
        }
    }

}
